<template>
  <el-row  >
        <el-tabs  >
              <el-tab-pane label="审批信息" name="first"></el-tab-pane>
        </el-tabs>

        <el-form  label-width="140px" align='left'  ref="form" :model='form' >
              <el-form-item label="审批名称：" >放款-</el-form-item>

              <el-form-item label="放款类型：" ></el-form-item>
              <el-form-item label="放款金额："  >
                    <el-input v-model="form.size"   class='w260'><template slot="suffix">元</template></el-input>
              </el-form-item>

              <el-form-item label="申请概述：">
                      <el-input type="textarea"  :rows="4"  placeholder="请输入内容"  v-model="form.textarea"></el-input>
              </el-form-item>

              <el-form-item label="审批文件：">
                    <el-button type="primary" icon="el-icon-plus" size="small" round  @click="addFiles"  class='mb16'>新增</el-button>
                    <el-table
                      :data="filelist"
                      header-row-class-name='bankheader' 
                      style="width: 100%">
                      
                            
                                <el-table-column  prop="fileName" label="文件名称"  align='center'></el-table-column>
                                <el-table-column   label="需要用印"  align='center'>
                                        <template slot-scope="scope">
                                            
                                              <el-radio v-model="scope.row.radio" :label="1">是</el-radio>
                                              <el-radio v-model="scope.row.radio" :label="0">否</el-radio>
                                            
                                                
                                      </template>
                                </el-table-column>
                                <el-table-column   label="份数"  align='center'>
                                      <template slot-scope="scope">
                                              <el-input-number v-model="scope.row.num" controls-position="right" :min="1" :max="10"  size='small'></el-input-number>
                                                
                                      </template>
                                </el-table-column>
                                <el-table-column  prop='tags' label="标签" align='center'>
                                        <template slot-scope="scope">
          
                                                <el-select v-model="scope.row.tags" multiple placeholder="搜索选择标签" filterable class='w-100' @change='(val)=>labelchange(val,scope.row)' >
                                                      <el-option
                                                        v-for="(item,index) in options"
                                                        :key="item.code"
                                                        :label="item.tagName"
                                                        :value="item.code">
                                                      </el-option>
                                                </el-select>
                                      </template>
                                </el-table-column>
                                <el-table-column   label="操作" align='center'>
                                      <template v-slot="list">
                                        
                                              <el-button  type="primary" size="mini" round @click="download( list.row.code)">下载</el-button>
                                              <el-button  type="danger"  size="mini" round @click="fileDelete( list.row.code)">删除</el-button>
                                      </template>
                                </el-table-column>


                                
                                
                            
                    </el-table>
              </el-form-item>

              <el-form-item label="印章种类：">
                    
                      <el-checkbox v-model="checked1" >公章</el-checkbox>
                      <el-checkbox v-model="checked2" >法人章</el-checkbox>

              </el-form-item>

              <el-form-item label="审批流程：">
                    
              </el-form-item>
        </el-form>
         <div  class="mt12 mb20">
              <el-button @click="common_goback()">取 消</el-button>
              <el-button type="primary" @click="submit('form')">发 起</el-button>
        </div>
        <!-- 新增 文件 -->
        <FileEdit ref='addFile'  v-on:save='recept(arguments)'> </FileEdit>
  </el-row>
  
</template>

<script>

//接口
import {  downloadFile } from '@/api/common/file'
import { listLabel } from '@/api/settings/label'

//组件
import FileEdit  from '@/components/common/FileEdit'

export default {
  name: 'clear_makeloans',
  data(){
    return {
      /*static*/
       options:[],
      /*active*/

      form:{

      },
       
      checked1:true,
      checked2:true,
        //审批文件
      filelist:[],

    }
  },
  created(){
      console.log(this.$route)
      this.pageInit()
  },
  methods:{
    pageInit(){
         
        let that =this
        listLabel({limit: 100,currentPage:1,}).then(response => {
          
          this.options = response.data.dataList
        })
        .catch(error => {

            that.outputError(error)
        })
          
    },
    //新增文件
    addFiles(){

        this.$refs.addFile.$emit('openDialog')
    },
    //接收已经上传的文件，并返回列表
    recept(arg){
        let  form = arg[0] 

        form.forEach((item,index)=>{
          this.filelist.push({fileName:item.name,fileCode:item.code,tags:item.labelname,radio:0,num:1})
        })
        // if(this.options.length == 0){
        //     this.options=arg[1]
        //     console.log(this.options)
        // }
          
    },
    //下载文件
    download(code){
        window.location.href=process.env.BASE_API+'/op/fileupload/download_file?fileCode='+code

    },
    //删除文件（新增时删除）
    fileDelete(index,row){
      this.common_del(index,this.filelist)
    },

   
  },
  components:{
    FileEdit
  }
}
</script>

<style>


</style>
